package org.example.design.facade.test1;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;


/**
 * @author huangshen
 * @version 0
 * @description DataBase
 * @since 2022/2/10 16:03
 */
@PropertySource("classpath:maildata.properties")
public class DataBase {

    @Value("${gugu@qq.com}")
    private String userName;

    DataBase(){}

    public Map<String,String> getValue() throws Exception{
        Map<String,String> map = new HashMap<>(8);
        final Field[] declaredFields = DataBase.class.getDeclaredFields();
        for (Field field : declaredFields) {
            final Value annotation = field.getAnnotation(Value.class);
            map.put(annotation.value(), (String) field.get(this));
        }
        return map;
    }
}
